package com.ce.pms.customer.model;

import java.util.Set;
import javax.persistence.*;
import org.hibernate.annotations.CascadeType;


import com.ce.pms.customer.model.ClientRHouseDO;
import com.ce.pms.customer.model.ParticipantDO;
import com.ce.pms.customer.model.ParticipantRoleDO;
import com.ce.pms.customer.model.PassportDO;

import com.ce.pms.common.model.SysInfo;
import com.ce.pms.common.model.SysrefcodeDO;
import com.sitechasia.webx.core.model.IDomainObject;

/**
 * 实体名称:客户
 * 关联表:CS_CLIENT
 * @author Adama Yue
 */
@Entity
@Table(name="CS_CLIENT")
@PrimaryKeyJoinColumn(name="CLIENT_ID")
public class ClientDO extends ParticipantRoleDO implements IDomainObject
{
	public static final String CT_OWNER = SysrefcodeDO.CLIENT_TYPE_OWNER;
	public static final String CT_LESSEE = SysrefcodeDO.CLIENT_TYPE_LESSEE;
	public static final String CT_OWNER_MEMBER = SysrefcodeDO.CLIENT_TYPE_OWNERMEMBER;
	public static final String CT_LESSEE_MEMBER = SysrefcodeDO.CLIENT_TYPE_LESSEEMEMBER;
	/**
	 * 001业主;002租户;003家庭成员
	 */
	@ManyToOne(cascade={},fetch=FetchType.EAGER)
	@JoinColumn(name="SYS_REF_ID",nullable=false)
   private SysrefcodeDO  clientType;//客户类型

   /**
    * 检索策略:lazy=false
    * 级联配置:cascade=save-update
    */
	@OneToMany(fetch=FetchType.LAZY,mappedBy="client")
	@org.hibernate.annotations.BatchSize(size = 4)
	@org.hibernate.annotations.Cascade({
		CascadeType.SAVE_UPDATE,
		CascadeType.DELETE_ORPHAN,
		CascadeType.DELETE
	})
   private Set<ClientRHouseDO> clientRHouses;//客户房屋关系

   /**
    * 检索策略:lazy=false
    * 级联配置:cascade=save-update
    */
	@OneToMany(fetch=FetchType.LAZY,mappedBy="client")
	@org.hibernate.annotations.Cascade({
		CascadeType.SAVE_UPDATE
	})
   private Set<PassportDO> passports;//出入证

	/**
	 * 检索策略:lazy=true
	 * 级联配置:none
	 */
   @OneToMany(fetch=FetchType.LAZY,mappedBy="client")
   private Set<GuestRecordDO> guestRecords;//出入证


   public ClientDO() { }
   /**
	 * mini constructor
	 * @param participant 参与人
	 * @param sysInfo 创建人信息等
    * @param clientType 客户类型
    */
   public ClientDO(ParticipantDO participant, SysInfo sysInfo, SysrefcodeDO clientType) {
	   super(participant, sysInfo);
	   this.clientType = clientType;
   }

   /**************************************************
    * Accessors and Modifiers
    **************************************************/
	public Set<ClientRHouseDO> getClientRHouses() {
		return clientRHouses;
	}
	public void setClientRHouses(Set<ClientRHouseDO> clientRHouses) {
		this.clientRHouses = clientRHouses;
	}
	public SysrefcodeDO getClientType() {
		return clientType;
	}
	public void setClientType(SysrefcodeDO clientType) {
		this.clientType = clientType;
	}
	public Set<PassportDO> getPassports() {
		return passports;
	}
	public void setPassports(Set<PassportDO> passports) {
		this.passports = passports;
	}
	public Set<GuestRecordDO> getGuestRecords() {
		return guestRecords;
	}
	public void setGuestRecords(Set<GuestRecordDO> guestRecords) {
		this.guestRecords = guestRecords;
	}



}
